package com.example.businesscalcproject;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class Acumulacao_Capital extends Activity{
	
	/*private WebView webview;
	private String codHTML = "<HTML>" ;*/
	private String tabela ="";
	private double acum = 0;
	private double i=0;
	private int n =0;
	private double a=0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.acumulacao_capital);
		//Log.d("Call","Entro");
		
		 Button tabelab = (Button) findViewById(R.id.depreTab);
		tabelab.setOnClickListener(new OnClickListener() {
		
				
	
	public void onClick(View v){
		EditText ac = (EditText) findViewById(R.id.valor_ac);
		 acum = Double.parseDouble(ac.getText().toString());
		
		EditText txjuro = (EditText) findViewById(R.id.valor_juros);
		 i = Double.parseDouble(txjuro.getText().toString())/100;
		
		EditText temp = (EditText) findViewById(R.id.valor_temp);
		 n = Integer.parseInt(temp.getText().toString());
		conta();
		enviatable();
	
	      }
	
		});
	}
		public void enviatable(){
			Intent intent = new Intent(this,Tabela_Acumulacao_Capital.class);
			intent.putExtra("html", tabela);
		    startActivity(intent);
		}
		
		private void conta(){
			
			
			for(int c = 1; c <=n; c++){
				a = (Math.pow((1+i), n))/1;
				acum +=a;
				
				if(c==1){
					tabela +="<tr>"+"<td width='75' nowrap='nowrap'>" +
			   				"<p style='text-align: center'>0</p>" +
			   				"</td>" +
			   				"<td width='164' nowrap='nowrap'>" +
	   				"<p style='text-align: center'>mes/juro</p>" +
	   				"</td>" +
	   				"<td width='153' nowrap='nowrap'>" +
	   				"<p style='text-align: center'>"+c+"</p>" +
	   				"</td>" +
	   				"</tr>"	;			
	   		 }
				else{
					tabela+=
			   				"<tr>"+"<td width='153' nowrap='nowrap'>" +
			   				"<p style='text-align: center'>"+acum+"</p>" +
			   				"</td>" +
			   				"</tr>";
				}
			
		}
		}
	
	
	
}
